﻿from AppKit import *
import NSImageExt
import NSBezierPathExt

CURSOR_SIZE = 32
CENTER = CURSOR_SIZE / 2

cursor_size = (CURSOR_SIZE, CURSOR_SIZE)
cross_path = NSBezierPath.alloc().init()
cross_path.setLineWidth_(1.0)
cross_path.moveToPoint_((CENTER, CENTER - 4))
cross_path.lineToPoint_((CENTER, CENTER + 4))
cross_path.moveToPoint_((CENTER - 4, CENTER))
cross_path.lineToPoint_((CENTER + 4, CENTER))
cursor_center = (CENTER, CENTER)

        
def getCursorWidth_color_(thickness, color):
    lowerleft = [(CURSOR_SIZE - thickness) / 2] * 2
    circle_size = [thickness] * 2
    cursor_image = NSImage.alloc().initWithSize_(cursor_size)
    cursor_image.lockFocus()
    if (thickness < 8):
        NSColor.grayColor().set()
        cross_path.stroke()
    circle = NSBezierPath.alloc().init()
    circle.appendBezierPathWithOvalInRect_((lowerleft,circle_size))
    color.set()
    circle.fill()
    cursor_image.unlockFocus()
    cursor = NSCursor.alloc().initWithImage_hotSpot_(cursor_image, cursor_center)
    return cursor
